package Tree;

import java.util.LinkedList;
import java.util.Queue;

public class Test {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        BinaryTree.TreeNode root = binaryTree.createTree();
        boolean flg =  binaryTree.isCompleteTree(root);
        System.out.println(flg);
    }
    public static void main3(String[] args) {
        //队列里面可以存放null值,如下所示:
        BinaryTree binaryTree = new BinaryTree();
        Queue<BinaryTree.TreeNode> myqueue = new LinkedList<>();
        myqueue.offer(null);
        myqueue.offer(null);
        myqueue.offer(null);
        System.out.println(myqueue.size());
    }


    public static void main2(String[] args) {
    BinaryTree binaryTree = new BinaryTree();
    //通过类名.静态内部类去创建根结点
    BinaryTree.TreeNode root = binaryTree.createTree();
//        System.out.println(root.val);
    binaryTree.preOrder(root);
    System.out.println();
    //----------
    binaryTree.midOrder(root);
    System.out.println();
    //-----------
    binaryTree.behOrder(root);
    System.out.println();

}
    public static void main1(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        //通过类名.静态内部类去创建根结点
        BinaryTree.TreeNode root = binaryTree.createTree();
//        System.out.println(root.val);
        binaryTree.preOrder(root);
        System.out.println();
        //----------
        binaryTree.midOrder(root);
        System.out.println();
        //-----------
        binaryTree.behOrder(root);
        System.out.println();
        //--树的结点总数---------------
        int size1 = binaryTree.size(root);
        System.out.println(size1);

        int size2 = binaryTree.size2(root);
        System.out.println(size2);

        //--树的叶子结点总数------------
        int leafsize1 = binaryTree.getLeafNodeCount(root);
        System.out.println(leafsize1);

        int leafsize2 = binaryTree.getLeafNodeCount2(root);
        System.out.println(leafsize2);

        //--第K层节点的个数
        System.out.println("==========");
        int knode = binaryTree.KNode(root,3);
        System.out.println("第k层节点数为 : "+knode);

        //--查找结点并返回其地址
        System.out.println("==========");
        BinaryTree.TreeNode find = binaryTree.find(root,'H') ;
        System.out.println("查找的结点是: "+find.val);
    }
}
